﻿@{
    ViewBag.Title = "Login";
    Layout = "~/Views/Shared/NonFilterLayout.cshtml";
}
<body class="login_body">
    <div class="login_box">
        <div class="bd">
            <div class="login_form">
                <form id="LoginForm" novalidate="novalidate">
                    <ul class="clearfix">
                        <li>
                            <div class="inptxt">
                                <label class="label"><i class="ico_user"></i><span class="intr">公司简称</span></label>
                                <input type="text" id="comp" name="comp">
                            </div>
                        </li>
                        <li>
                            <div class="inptxt">
                                <label class="label"><i class="ico_user"></i><span class="intr" style="display: none;">用户名</span></label>
                                <input type="text" id="username" name="username" aria-required="true" aria-invalid="false" class="valid">
                            </div>
                        </li>
                        <li>
                            <div class="inptxt">
                                <label class="label"><i class="ico_key"></i><span class="intr" style="display: none;">密码</span></label>
                                <input type="password" id="password" name="password" autocomplete="off" aria-required="true" aria-invalid="false" class="valid">
                            </div>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <div class="fd">
            <div class="load_btn" style="text-align:center">
                <button class="btn_blue" id="login" data-name="Loginnew" data-action="login">登录</button>
            </div>
        </div>
    </div>


    <div style="width:100%;margin:0 auto;position:fixed;bottom:0;text-align:center">
        Copyright &copy;
        <script>document.write(new Date().getFullYear());</script>维数智能科技有限公司 visu-tech.com All Right Reserved 丨<a target="_blank" href="http://www.miitbeian.gov.cn">鄂ICP备18027379号-1</a>
        <br />
        <br>
    </div>
    <script type="text/javascript">
        $(function () {
            $("#comp, #username, #password").click(function () {
                $(this).closest("li").find(".intr").hide();
                $(this).removeClass("error");
                $(this).parent().addClass("on").removeClass("error")

            }).blur(function () {
                "" == $(this).val() && $(this).closest("li").find(".intr").show();
                $(this).parent().removeClass("on")

            });

            $("#login").click(function () {
                $("#LoginForm").valid() && $.ajax({
                    
                    url: "/Home/LoginMethod",
                    dataType: "json",
                    data: { comp: $("#comp").val(), username: $("#username").val(), password: $("#password").val(), auto: $("#auto").val() },
                    success: function (data) {
                        if (data.state == "success") {
                            window.location.href = "/Home/Index";

                        } else if (data.state == "comError") {
                            $("#comp").addClass("error").parent().addClass("error").append('<span class="error">' + data.msg + "<i></i></span>")
                        } else {
                            $("#username").addClass("error").parent().addClass("error").append('<span class="error">' + data.msg + "<i></i></span>");

                            $("#password").addClass("error").parent().addClass("error").append('<span class="error">' + data.msg + "<i></i></span>")
                        }
                    }
                })
            });

            $(document).keydown(function (event) {
                if ("13" == event.keyCode) {
                    $("#login").click();
                }
            });

            $("#spnDownload").click(function () {
                window.location.href = "/Download/DownloadApp?t=" + new Date().getTime();;
            });
        })

    </script>
</body>